<div id="main">
	<div class="hr">
		<hr />
	</div>
	<div id="example">

	<?php
	//		$admin = $_SESSION['admin'];
	//		$userid = $_SESSION['userid'];
	//		if (($admin == "") && ($userid == "")) {
	//			echo "<h2>请先登陆</h2>";
	//		}
	//		else
	//		{
	
	require 'ShopDAO.inc';
	require 'conn.php';
	$shop_id = $_REQUEST['shop_id'];
	$name = trim($_POST['shopname']);
	$title = trim($_POST['shoptitle']);
	$address = trim($_POST['shopaddress']);
	$telephone = trim($_POST['shopphone']);
	$email = trim($_POST['shopemail']);
	$latitude = trim($_POST['shoplatitude']);
	$longitude = trim($_POST['shoplongitude']);
	$description = trim($_POST['shopdescription']);
	$details = trim($_POST['shopdetails']);
	$area_id = trim($_POST['area']);

	if (($name == "") or ($title == "") or ($address == "") or ($telephone == "") or ($email == "") or ($latitude == "") or ($longitude == "") or ($description == "")) {
		echo "<script language=javascript>alert('带*号的选项必须填写全'); history.go(-1)</script>";
		exit;
	}
		
	if (!preg_match("/(\d{3}-)(\d{8})$|(\d{4}-)(\d{7,8})$/",$telephone)&&!preg_match("/13[0-9]{9}|15[0|1|2|3|5|6|7|8|9]\d{8}|18[0|5|6|7|8|9]\d{8}/",$telephone))
	{
		echo "<script language=javascript>alert('错误：电话或者手机号码格式不正确'); history.go(-1)</script>";
		exit;
	}
	if (!preg_match("/([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?/i", $email))
	{
		echo "<script language=javascript>alert('错误：邮件格式不正确'); history.go(-1)</script>";
		exit;
	}
		
	if ($latitude<-180 or $latitude>180)
	{
		echo "<script language=javascript>alert('错误：纬度数值不正确'); history.go(-1)</script>";
		exit;
	}
		
	if ($longitude<-180 or $longitude>180)
	{
		echo "<script language=javascript>alert('错误：经度数值不正确'); history.go(-1)</script>";
		exit;
	}

	$shop = new shop();
	$shop -> editshop($shop_id,$name, $title, $address, $telephone, $email, $latitude, $longitude, $description, $details, $area_id);
		
	$query = "SELECT * FROM images WHERE shop_id=".$shop_id;
		
	
	echo "<a href='viewImages.php?shopid=".$shop_id."'>修改店铺图片</a>";
?>
</div>
</div>
